package com.tank.bean.msg;

import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.directwebremoting.annotations.DataTransferObject;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.GenericGenerator;

import com.tank.bean.User;


@DataTransferObject
@Entity
public class PmTracker {
	
	@Override
	public String toString() {
		StringBuilder sb=new StringBuilder();
		
		
		sb.append("{");
		sb.append("id:").append(id).append(",");
		sb.append("unreadCount:").append(unreadCount).append(",");
		sb.append("totalCount:").append(totalCount).append(",");
		sb.append("lastTime:").append(lastTime).append(",");
		
		sb.append("}");
		return sb.toString();
	}
	
	@GenericGenerator(name = "gen", strategy = "increment")
	@Id
	@GeneratedValue(generator = "gen")
	private Integer id;
	
	@ManyToOne
	@Fetch(FetchMode.JOIN)
	private User author;
	
	

	@ManyToOne
	
	private PmDialog dialog;
	
	
	private Integer unreadCount;
	
	private Integer totalCount;
	
	
	@ManyToOne
	private PmContent lastPm;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastTime;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public PmDialog getDialog() {
		return dialog;
	}
	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}
	public void setDialog(PmDialog dialog) {
		this.dialog = dialog;
	}

	public Integer getUnreadCount() {
		return unreadCount;
	}

	public void setUnreadCount(Integer unreadCount) {
		this.unreadCount = unreadCount;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
	}

	public PmContent getLastPm() {
		return lastPm;
	}

	public void setLastPm(PmContent lastPm) {
		this.lastPm = lastPm;
	}

	public Date getLastTime() {
		return lastTime;
	}

	public void setLastTime(Date lastTime) {
		this.lastTime = lastTime;
	}
	
}
